<?php
//Latest Seyret Module v.0.2//
/**
* Content code
* @package Latest Seyret
* @Copyright (C) 2007 Mustafa DINDAR
* @ All rights reserved
* @ latest seyret module is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version 0.2
**/	

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

global $database, $mosConfig_live_site, $mosConfig_absolute_path, $mainframe;


$videocount 		= $params->get( 'count' );
$showtitles 		= $params->get( 'showtitles' );
$videothumbwidth 	= $params->get( 'videothumbwidth' );
$videothumbheight 	= $params->get( 'videothumbheight' );
$showsubmitter 		= $params->get( 'showsubmitter' );
$showaddeddate  	= $params->get( 'showaddeddate' );

	$database->setQuery("SELECT * FROM #__seyret_items WHERE published='1' ORDER BY addeddate DESC LIMIT 0, $videocount");
	$vidyo = $database->loadObjectList();
		echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"text-align:center;\">";
		foreach ($vidyo as $vidyo) {
		$vid=$vidyo->id;
		$vhit=$vidyo->hit;
		$vtitle=$vidyo->title;
		$vpicturelink = $vidyo->picturelink;
		$votes=$vidyo->voteclick;
		$vratingtotal=$vidyo->votetotal;
		$vaddedby=$vidyo->addedby;
		$vaddedbyname=jaseyretlatestvideomodulegetusersname($vaddedby);
		$vaddeddate=$vidyo->addeddate;
		$link=$mosConfig_live_site."/index.php?option=com_seyret&task=videodirectlink&id=".$vid;
		
			echo "<tr><td>";

			if ($showtitles=="1") {
			echo "<a href=".$link.">".$vtitle."</a><br>";
			}
			
			echo "<a href=".$link."><img src=\"".$vpicturelink."\" width=\"".$videothumbwidth."\" height=\"".$videothumbheight."\" alt=\"".$vtitle."\" style=\"border:none;\"/></a><br>";

			if ($showsubmitter=="1") {
			echo $vaddedbyname."<br>";
			}

			if ($showaddeddate=="1") {
			echo $vaddeddate."<br>";
			}


			echo "</td></tr>";		
		}
		
		echo "</table>";


function jaseyretlatestvideomodulegetusersname($id) {
global $database, $my;

		$database->setQuery("SELECT name FROM #__users WHERE id='$id'"); 		
		$usname = $database->loadObjectList();
		foreach ($usname as $usname) 
		{
		$username=$usname->name;
		}
	
	return $username;
}	
